package com.qingcheng.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.entity.Result;
import com.qingcheng.pojo.order.CategoryReport;
import com.qingcheng.service.order.CategoryReportService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName: qingcheng_parent
 * @ClassName: CategoryReportController
 * @Time: 2019/6/29
 * @Author: zhou24
 * @Description:
 * @Experience:
 */
@RestController
@RequestMapping("/categoryReport")
public class CategoryReportController {
    @Reference
    private CategoryReportService categoryReportService;

    @RequestMapping("/yesterday")
    public List<CategoryReport> yesterday() {
        LocalDate localDate = LocalDate.now().minusDays(1);
        return categoryReportService.findCategoryReport(localDate);
    }

    @GetMapping("/dateOrder")
    public List<CategoryReport> dateOrder() {
        String date = "2019-01-26";
        return categoryReportService.dateOrder(date);
    }

    /**
     * 测试定时插入使用
     *
     * @return
     */
    @GetMapping("/timeingFindCategoryReport")
    public Result timeingFindCategoryReport() {
        categoryReportService.timeingFindCategoryReport();
        return new Result();
    }

    /**
     * 统计一级类目
     *
     * @param date1
     * @param date2
     * @return
     */
    @GetMapping("/category1Count0")
    public List<Map> category1Count0(String date1, String date2) {
        return categoryReportService.category1Count0(date1, date2);
    }

    @GetMapping("/category1Count")
    public List<Map> category1Count(String date1, String date2) {
        return categoryReportService.category1Count(date1, date2);
    }


}
